<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateUsersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('users', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('name', 191);
			$table->string('email', 191)->nullable()->default('');
			$table->string('password', 191)->nullable();
			$table->string('remember_token', 100)->nullable();
			$table->timestamps();
			$table->string('mobile', 100)->nullable();
			$table->string('true_name', 100)->nullable()->comment('真实姓名');
			$table->integer('team_level_id')->nullable()->default(0)->comment('会员等级id 0 普通会员');
			$table->decimal('distribution_money', 10)->nullable()->default(0.00)->comment('分销金额 按分计算');
			$table->decimal('distribution_used_money', 10)->nullable()->default(0.00)->comment('分销结算的金额');
			$table->decimal('money', 10)->nullable()->default(0.00)->comment('总金额');
			$table->decimal('team_money', 10)->nullable()->default(0.00)->comment('用户团队奖励金额');
			$table->decimal('team_used_money', 10)->nullable()->default(0.00)->comment('团队结算的金额');
			$table->string('openid', 100)->nullable()->comment('openid');
			$table->string('team_path')->nullable()->comment('团队树节点 用,分割 ');
			$table->integer('team_leader')->nullable()->comment('上级领导');
			$table->string('headimgurl')->nullable()->comment('微信头像');
			$table->integer('sex')->nullable();
			$table->string('city', 50)->nullable();
			$table->string('province', 50)->nullable();
			$table->string('country', 50)->nullable();
			$table->integer('promotion_number')->nullable()->default(0)->comment('推广人数 判断团队升级等级');
			$table->integer('is_recharge')->nullable()->default(0)->comment('是否是复购 0 否 1 是');
			$table->decimal('consume', 10)->nullable()->default(0.00)->comment('消费额');
			$table->decimal('distribution_total_sale', 10)->nullable()->default(0.00)->comment('推广订单销售量');
			$table->decimal('team_total_sale', 10)->nullable()->default(0.00)->comment('团队订单销售量');
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('users');
	}

}
